#!/bin/bash
#安装开发包
yum -y groupinstall "Development tools"
#安装依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
#解压
tar -xJvf Python-3.7.0.tar.xz
#进入解压文件
cd Python-3.7.0
#准备编译
./configure --prefix=/usr/local/python3  --enable-shared
#编译
make
#安装
make install
#配置环境变量
rm -rf /usr/bin/python
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
cp libpython3.7m.so.1.0 /usr/lib64/libpython3.7m.so.1.0
#调整yum对python需求
rm -rf /usr/bin/yum
cp ../yum /usr/bin/yum
chmod +x /usr/bin/yum
rm -rf /usr/libexec/urlgrabber-ext-down
cp ../urlgrabber-ext-down /usr/libexec/urlgrabber-ext-down
chmod +x /usr/libexec/urlgrabber-ext-down

